package org.example.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.example.bean.RedPacketActivity;

import java.util.List;

public interface RedPacketMapper extends BaseMapper<RedPacketActivity> {
    //查询最新一条记录
    @Select("select * from red_packet_activity order by id desc limit 1;")
    RedPacketActivity getLatestRedPacketActivity();

    //查询所有的活动
//    @Select("select *\n" +
//            "from red_packet_activity ra\n" +
//            "left join user_red_packet urp on ra.id=urp.activity_id")
//    @Results({
//            @Result(column = "id",property = "id"),
//            @Result(column = "title",property = "title"),
//            @Result(column = "total_amount",property = "total_amount"),
//            @Result(column = "total_packets",property = "total_packets"),
//            @Result(column = "start_time",property = "start_time"),
//            @Result(column = "end_time",property = "end_time"),
//            @Result(column = "status",property = "status"),
//            @Result(column = "user_id",property = "userRedPacket.user_id"),
//            @Result(column = "amount",property = "userRedPacket.amount"),
//            @Result(column = "received_at",property = "userRedPacket.received_at"),
//    })
//    List<RedPacketActivity> getAllRedPacketActivity();
}
